"use client"; import { getCommissionApi, getRegisterCountApi, getTotalCountApi, getWithdrawalApi, } from "@/api/summary"; import { useUserInfoStore } from "@/stores/useUserInfoStore"; import { useRequest } from "ahooks"; import { Toast } from "antd-mobile"; import { useLocale, useTranslations } from "next-intl"; import { getToken } from "@/utils/Cookies"; import { copyText } from "@/utils/methods"; import { FC, useRef, useState } from "react"; import "./page.scss"; interface Props {} const App: FC = (props) => { const t = useTranslations("SummaryPage"); const locale = useLocale(); const sliderRef = useRef(null); const [num, setNum] = useState(100); const [money, setMoney] = useState("5000"); const { userInfo } = useUserInfoStore(); const token = getToken(); // 生成分享链接 const BASE_URL = process.env.NEXT_PUBLIC_SHARE_URL; const shareUrl = `${BASE_URL}/${locale}/${userInfo ? userInfo.referrer_code : "xxxxxx"}`; // 轮询时间 const TIME = 180000; const getUserMoneyHandler = () => { if (token) { return getRegisterCountApi().then((res) => { if (res.code === 200) return res.data; }); } return Promise.resolve({ commissar: 0, effective_amount: 0, recharge_user_count: 0, reg_count: 0, }); }; const { data: todayData } = useRequest(getUserMoneyHandler, { pollingInterval: TIME, pollingWhenHidden: true, pollingErrorRetryCount: 3, staleTime: 5000, refreshDeps: [token], }); const getTotalCount = () => { if (token) { return getTotalCountApi().then((res) => { if (res.code === 200) return res.data; }); } return Promise.resolve({ commissar: 0, effective_amount: 0, recharge_user_count: 0, reg_count: 0, }); }; const { data: totalData } = useRequest(getTotalCount, { pollingInterval: TIME, pollingWhenHidden: true, pollingErrorRetryCount: 3, staleTime: 5000, refreshDeps: [token], }); const getCommission = () => { if (token) { return getCommissionApi().then((res) => { if (res.code === 200) return res.data; }); } return Promise.resolve({ commissar: 0, level: 0, withdrawal_commissions: 0, enable_receive: false, min_value: 0, max_value: 0, }); }; const { data: commissionData, run: commissionRun } = useRequest(getCommission, { pollingInterval: TIME, pollingWhenHidden: true, pollingErrorRetryCount: 3, staleTime: 5000, refreshDeps: [token], }); const handleSlide: any = (e: React.MouseEvent) => { if (sliderRef.current) { const startX = sliderRef.current.getBoundingClientRect().x; const x = e.clientX - startX; const xRem = x / (144 * 0.6); const intNum = Math.round(10000 * xRem) - Math.round((10000 * xRem) % 10); setNum(intNum); const m = intNum * 50; let r = ""; const arr = m.toString().split(""); arr.forEach((item, i) => { if (i !== arr.length - 1 && (arr.length - i - 1) % 3 === 0) { r += item + ","; } else { r += item; } }); setMoney(r); const scale = (Math.round(xRem * 10000) / 100.0).toFixed(2) + "%"; sliderRef.current.style.width = scale; } }; const copy = (text: string) => { copyText(text); Toast.show({ icon: "success", content: t("copySuc"), maskClickable: false }); }; const withdrawalHandler = async () => { if (commissionData?.commissar) return; if ( commissionData?.enable_receive && commissionData.commissar! > Math.min(commissionData.min_value, 10) ) { const available = commissionData.max_value > commissionData.commissar! ? commissionData.max_value : commissionData.commissar; await getWithdrawalApi({ amount: available! }); // 间隔时间 setTimeout(() => { commissionRun(); }, 100); } else { Toast.show(t("receive")); } }; return (
{t("Hoje")}
  • {todayData?.reg_count}

    {t("Inscrições")}

  • {todayData?.recharge_user_count}

    {t("Novos")}

  • {t("R$")} {todayData?.effective_amount}

    {t("Aposta")}

  • {t("R$")} {todayData?.commissar}

    {t("Comissão")}

{t("Total")}
  • {totalData?.reg_count}

    {t("Inscrições")}

  • {totalData?.recharge_user_count}

    {t("Jogadores")}

  • {t("R$")} {totalData?.effective_amount}

    {t("ApostaTotal")}

  • {t("R$")} {totalData?.commissar}

    RS {t("Comissão")}

{t("Comissão")}
{commissionData?.level}
{t("Nível")}
  • {t("R$")} {commissionData?.withdrawal_commissions}

    {t("TotalPago")}

  • {t("R$")} {commissionData?.commissar}

    {t("Não")}

{t("TRANSFERIR")}
{t("Valor")}
{t("title1")}
  • {t("Facebook")}
  • {t("WhatsApp")}
  • {t("Telegram")}
  • {t("Twitter")}
  • {t("Email")}
{t("content1")}
{shareUrl} copy(shareUrl)}> {t("Cópia")}
{t("title2")}
{t("content2-1")}
{t("content2-2")} {t("business")}
{t("title3")}
{t("content3")}
{t("number")} {num}
{t("Comissão")} > {t("R$")} {money} {t("money")}
{t("title4")}
  • {t("content4-1")} {t("red")}.
  • {t("content4-2")}
); }; export default App;